
local file = io.open(arg[1],"rb");
assert(file,"open file error:"..arg[1]);
local offset = tonumber(arg[2]) or 0;
offset = offset + 1;
local data = file:read('*a');
local len = (tonumber(arg[3]) and tonumber(arg[3]) + offset) or #data;
if(len>#data)then len = #data; end
local out = io.stdout;
local err = io.stderr;
err:write(string.format('offset:%d,%d\n',offset-1,len));
for k=offset,len do
    local byte = string.byte(data,k);
    local hex = string.format('%02X ',byte);
    out:write(hex);
    if((k-offset+1)%0x10==0)then
        --换行
        out:write('\n');
    end
end
